<?php

class ResultadoEstudio
{
	public $nombreEstudio = "";
	public $resultado ="";
	
}


class IngresoPacienteController extends Controller
{
		
	public $idPaciente;
	
	public function actionCreate()
	{
		$this->render('create');
	}

	public function actionIndex()
	{
		$this->render('index');
	}

	public function actionView()
	{
		$this->render('view');
	}
	
	/*
	public function getEstudios($etapa){
		
		$model=new Tipoestudio();
		$estudios = $model->findAllByAttributes(array('idEtapa'=>$etapa));
		
		return  $estudios;
		
	}
	*/
	
	public function actionUpdateEstudioPaciente2(){

		// retrieve items to be updated in a batch mode
	    // assuming each item is of model class 'Item'

		$model=new Estudiopaciente();
		
		$items=$model->getDetalleEstudioInstances(1,1);
	    if(isset($_POST['Detalleestudiopaciente']))
	    {
	    	
	        $valid=true;
	        foreach($items as $i=>$item)
	        {
	            if(isset($_POST['Detalleestudiopaciente'][$i]))
	                $item->attributes=$_POST['Detalleestudiopaciente'][$i];
	            	$valid=$item->validate() && $valid;
	        }
	        if($valid){
	        	// all items are valid
	            // ...do something here	
	       	 foreach($items as $i=>$item)
	        	{
	        		$item->save();
	        	}
	        }

	    };
	    
	    // displays the view to collect tabular input
	    $this->render('create',array('items'=>$items));
	}
	/*
	public function getDetalleEstudioInstances($idEstudioPaciente, $idEtapa){

		
		$tipoEstudios = $this->getEstudios($idEtapa);
		$detalleEstudioModel = new Detalleestudiopaciente();
		
		$detalleEstudios = array();
		
		foreach ($tipoEstudios as $tipoEstudio){
			
			$currentDetalleEstudios = $detalleEstudioModel->findAllByAttributes(array('idEstudioPaciente'=>$idEstudioPaciente,'idTipoEstudio'=>$tipoEstudio->idTipoEstudio));
			
			if (count($currentDetalleEstudios) != 0){
				$newDetalleEstudio = $currentDetalleEstudios[0];				
			}else{
				
				$newDetalleEstudio = new Detalleestudiopaciente();
				$newDetalleEstudio->idEstudioPaciente = $idEstudioPaciente;
				$newDetalleEstudio->idTipoEstudio = $tipoEstudio->idTipoEstudio;

			}
			$newDetalleEstudio->nombreEstudio = $tipoEstudio->nombreEstudio;
			array_push($detalleEstudios, $newDetalleEstudio);
			
		}
		
		return $detalleEstudios;
		
	}
	*/
	

// http://www.yiiframework.com/forum/index.php/topic/26617-how-to-run-sql-statement-in-yii/

	// Uncomment the following methods and override them if needed
	/*
	public function filters()
	{
		// return the filter configuration for this controller, e.g.:
		return array(
			'inlineFilterName',
			array(
				'class'=>'path.to.FilterClass',
				'propertyName'=>'propertyValue',
			),
		);
	}

	public function actions()
	{
		// return external action classes, e.g.:
		return array(
			'action1'=>'path.to.ActionClass',
			'action2'=>array(
				'class'=>'path.to.AnotherActionClass',
				'propertyName'=>'propertyValue',
			),
		);
	}
	*/
}